import java.util.Scanner;

public class 第5题_最长回文子串 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String str = sc.next();
            System.out.println(longestPalindrome(str));
        }
    }

    /**
     * 分别从1个字母到n个字母去计算回文数
     * 2019/11/25 18:01
     */
    public static String longestPalindrome(String s) {
        int n = s.length();
        if (n == 0) {
            return "";
        }
        if (n == 1) {
            return s;
        }
        int maxI = 1, maxJ = 1;
        int[][] maxArray = new int[n + 2][n + 2];
        for (int temp = 0; temp < n; temp++) {
            for (int i = 1; i < n + 1; i++) {
                if (i + temp < n + 1 && s.charAt(i - 1) == s.charAt(i - 1 + temp)) {
                    if (temp == 0) {
                        maxArray[i][i] = 1;
                    }
                    if (temp == 1) {
                        maxArray[i][i + temp] = 2;
                        maxArray[i + temp][i] = 2;
                    }
                    if (temp > 1 && maxArray[i + 1][i + temp - 1] > 0) {
                        maxArray[i][i + temp] = maxArray[i + 1][i + temp - 1] + 2;
                        maxArray[i + temp][i] = maxArray[i + 1][i + temp - 1] + 2;
                    }
                    if (maxArray[i][i + temp] > maxJ - maxI) {
                        maxI = i;
                        maxJ = i + temp;
                    }
                }
            }
        }
        return s.substring(maxI - 1, maxJ);
    }
}
